package logic

import (
	"2211a_mayi/service/models"
	"context"

	"2211a_mayi/service/internal/svc"
	"2211a_mayi/service/mayi"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateOrderLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUpdateOrderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateOrderLogic {
	return &UpdateOrderLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UpdateOrderLogic) UpdateOrder(in *mayi.UpdateOrderRequest) (*mayi.UpdateOrderResponse, error) {
	var order models.Order
	err := order.Update(in.OrderSn, int(in.OrderStatus))
	if err != nil {
		logx.Error(err)
		return nil, err
	}

	return &mayi.UpdateOrderResponse{}, nil
}
